﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace IndexMarkSilverlightClient.IndexMarkServiceReference
{
    public partial class Department
    {
        public override string ToString()
        {
            //return this.Type + " " + this.Name;
            //return Abbriviation + " (" + Type + ")";
            return this.Name;
        }

        public bool ContaintsResp(Respondent respondent)
        {
            bool flag = false;

            if (respondent == null) throw new ArgumentNullException("respondent", "параметр respondent не может быть null.");
            if (respondent.Department == null) throw new ArgumentNullException("respondent.Department", "параметр respondent.Department не может быть null.");

            if (respondent.Department.IDDepartment == IDDepartment)
                return true;

            foreach (DTOBase DTO in this.Childs)
            {
                Department department = (DTO as Department);
                if (department != null)
                    flag = flag || department.ContaintsResp(respondent);
            }
            return flag;

        }

        public bool Check { get; set; }
    }
}
